package com.huangbc.servicepassengeruser.controller;

import com.huangbc.internalcommon.dto.ResponseResult;
import com.huangbc.internalcommon.dto.VerificationCodeDTO;
import com.huangbc.servicepassengeruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Derek.huang on 2024/3/28 11:27.
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/loginOrRegister")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){

        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        System.out.println("手机号："+passengerPhone);
        return userService.loginOrRegister(passengerPhone);

    }

    @PostMapping("/user")
    public ResponseResult getUser(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        return userService.getUserByPhone(passengerPhone);
    }
}

